import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  strict: true,   //true为打开严格模式
  state: {
    curPosition: {
     
    },
    userName:'',
    userPhoto:''
    // userPhoto:'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1253175641,3009092832&fm=26&gp=0.jpg'
  },
  mutations: {
      setPosition (state,position) {
        state.curPosition=position;
    },
    setUserName(state,userName){
      state.userName=userName;
      if(userName){
        state.userPhoto='https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1253175641,3009092832&fm=26&gp=0.jpg';
      }
    }
  },
  actions: {
    setPosition ({ commit }, val) {
      // 异步请求后端获取当前位置数据
      commit('setPosition', val)
    },
  },
  modules: {
    
  }
})
